﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class admin_func_ctiy_s_count : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int no = int.Parse(Request["no"]);

        ctpDataContext db = new ctpDataContext();

        var data = from p in db.ct_s_profiles
                   where p.ct_no == no && p.valid == true
                   select new
                   {
                       title = p.title,
                       url = "~/admin/func/city_s_count.aspx?no=" + p.no,
                       count = reviewcount(p.no),
                       piccount = piccount(p.no),
                       introcount = introcount(p.no)
                   };
        this.GridView1.DataSource = data;
        this.GridView1.DataBind();
    }

    private int reviewcount(int no)
    {
        ctpDataContext db = new ctpDataContext();

        return (db.ct_s_reviews.Count(p => p.ct_s_no == no));
    }
    private int piccount(int no)
    {
        ctpDataContext db = new ctpDataContext();

        return (db.ct_s_pics.Count(p => p.ct_s_no == no));
    }
    private int introcount(int no)
    {
        ctpDataContext db = new ctpDataContext();

        return (db.ct_s_intros.Count(p => p.ct_s_no == no));
    }
}
